package com.paiai.lslease.base;

import com.dsmzg.base.util.ConfigUtil;
import com.dsmzg.base.util.encrypt.CodeUtil;

/**
 * @description FTP常量类
 * @author chenmfa
 */
public class FTPConstants {
  public static String host = ConfigUtil.getConfig("server.httpdhost");
  public static String username = ConfigUtil.getConfig("server.filesystemuser");
  //密码是经过CodeUtil.encode()加密的;
  public static String password = CodeUtil.decodeLocal(ConfigUtil.getConfig("server.filesystempassword"));
  
  //文件根目录
  private static String docroot = ConfigUtil.getConfig("server.httpd_docroot","/home/data/www");
  //http上传基础目录
  private static String uploadFolder =ConfigUtil.getConfig("server.uploadfolder","/upload");
  //文件服务器根目录
  private static String serverBaseFolder = "http://"+ConfigUtil.getConfig("server.httpdhost","cdn.dsmzg.com")
      +":"+ConfigUtil.getConfig("server.httpdport","80");
  //头像的相对路径
  public static String photoRelativePath = uploadFolder + "/userphotos/";
  //头像文件的绝对路径
  public static String photoPath = docroot+photoRelativePath;
  //头像问件服务器路径
  public static String photoServer = serverBaseFolder + photoRelativePath;
  
  //礼品上传的后台图像相对路径
  public static String giftRelativePath = uploadFolder + "/gift/";
  //头像文件的绝对路径
  public static String giftPath = docroot+giftRelativePath;
  //头像问件服务器路径
  public static String giftServer = serverBaseFolder + giftRelativePath;
  
  
  //错误日志上传路径
  public static String debugFileRelativePath = uploadFolder+ "/debugUpload/";
  //错误日志上传路径
  public static String debugFilePath =  docroot+debugFileRelativePath;
  //错误日志服务器路径
  public static String debugFileServer = serverBaseFolder + debugFileRelativePath;
    
  public static void reloadConstants(){
    host = ConfigUtil.getConfig("server.httpdhost");
    username = ConfigUtil.getConfig("server.filesystemuser");
    password = CodeUtil.decodeLocal(ConfigUtil.getConfig("server.filesystempassword"));
    //文件根目录
    docroot = ConfigUtil.getConfig("server.httpd_docroot","/home/data/www");
    //http上传基础目录
    uploadFolder =ConfigUtil.getConfig("server.uploadfolder","/upload");
    //文件服务器根目录
    serverBaseFolder = "http://"+ConfigUtil.getConfig("server.httpdhost","cdn.dsmzg.com")
        +":"+ConfigUtil.getConfig("server.httpdport","80");
    
    //文件的相对路径
    photoRelativePath = ConfigUtil.getConfig("server.uploadfolder","/upload") + "/userphotos/";
    //文件的绝对路径
    photoPath = docroot+photoRelativePath;
    //服务器路径
    photoServer = "http://"+ConfigUtil.getConfig("server.httpdhost","cdn.dsmzg.com")
          +":"+ConfigUtil.getConfig("server.httpdport","80")+photoRelativePath;
    
    //错误日志上传路径
    debugFileRelativePath = "/debugUpload/";
    //错误日志上传路径
    debugFilePath =  docroot+debugFileRelativePath;
    //错误日志服务器路径
    debugFileServer = "http://"+ConfigUtil.getConfig("server.httpdhost","cdn.dsmzg.com")
          +":"+ConfigUtil.getConfig("server.httpdport","80")+debugFileRelativePath;
  }
}
